package com.tancire.web.controller.net;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.net.domain.PurseLog;
import com.tancire.net.service.IPurseLogService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 会员钱包流水Controller
 *
 * @author chenchao
 * @date 2023-12-02
 */
@RestController
@RequestMapping("/net/purseLog")
public class PurseLogController extends BaseController {
    @Resource
    private IPurseLogService purseLogService;

    /**
     * 查询会员钱包流水列表
     */
    @PreAuthorize("@ss.hasPermi('net:purseLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(PurseLog purseLog) {
        startPage();
        List<PurseLog> list = purseLogService.selectPurseLogList(purseLog);
        return getDataTable(list);
    }

    /**
     * 导出会员钱包流水列表
     */
    @PreAuthorize("@ss.hasPermi('net:purseLog:export')")
    @Log(title = "会员钱包流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurseLog purseLog) {
        List<PurseLog> list = purseLogService.selectPurseLogList(purseLog);
        ExcelUtil<PurseLog> util = new ExcelUtil<PurseLog>(PurseLog.class);
        util.exportExcel(response, list, "会员钱包流水数据");
    }

    /**
     * 获取会员钱包流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:purseLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(purseLogService.selectPurseLogById(id));
    }

    /**
     * 删除会员钱包流水
     */
    @PreAuthorize("@ss.hasPermi('net:purseLog:remove')")
    @Log(title = "会员钱包流水", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(purseLogService.deletePurseLogByIds(ids));
    }
}
